		**********************************************************
		** File: cleaning_fh_media.do							**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning Freedom House Media					**
 		**********************************************************


		clear
		version 16.1
		set seed 1234
		set more off
		clear matrix
		clear mata

		cd "~/"
				
		import excel "FOTP1980-FOTP2017_Public-Data.xlsx", sheet("Data") cellrange(A3:FZ215) firstrow

		* DROPPING YEARS BEFORE 2001 REPORT (2000 DATA)
			
		rename PressFreedomEdition country
		keep country CW DB DG DL DQ DV EA EF EK EP EU EZ FE FJ FO FT FY
		rename CW y2000
		rename DB y2001
		rename DG y2002
		rename DL y2003
		rename DQ y2004
		rename DV y2005
		rename EA y2006
		rename EF y2007
		rename EK y2008
		rename EP y2009
		rename EU y2010
		rename EZ y2011
		rename FE y2012
		rename FJ y2013
		rename FO y2014
		rename FT y2015
		rename FY y2016
		drop in 1/2
		reshape long  y, i(country) j(year)
		rename y mediafreedom
		replace media ="" if media=="-"
		destring media, replace
		label var media "Media freedom (Freedom House)"
		label var country "Country name"
		rename country Country
		run "cow.do"
		rename Country country
		tab country if ccode==0
		drop if ccode==0
		sort ccode year
		duplicates report ccode year
		
		drop if country=="Yugoslavia"
		drop if country=="Serbia" & year<2006
		drop if country=="Serbia and Montenegro" & year>2005
		drop if country=="Kosovo" & year<2009
		drop if country=="Cyprus" & media==.
		drop if country=="USSR"
		drop if country=="Transkei"
		drop if country=="Hong Kong"	
		drop if country=="Somaliland"
	
		sort country
		save "FH media 2017.dta", replace
	
